<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<c:set var="disableBtn" value=""/>
<c:if test="${canAddOrUpdate ne true}"><c:set var="disableBtn" value=" disabled='true' "/></c:if>

<c:out value="${param.field_info}" escapeXml="false"/>

<form:form action="course.pt" method="POST">
<input type="hidden" name="action_value" id="idActionValue" value="" />
<input type="hidden" name="selection_value" id="idSelectionValue" value="" />

<form:errors path="*" cssClass="error-message"/>

<div class="subheader">Course Details:</div>
<table class="input-table">
	<tbody>
		<tr>
			<td width="20%">Name<c:out value="${param.field_mandatory}" escapeXml="false"/></td>
			<td width="*"><form:input path="name" cssClass="input-text"/></td>
		</tr>
		<tr>
			<td width="20%">Course ID<c:out value="${param.field_mandatory}" escapeXml="false"/></td>
			<td width="*"><form:input path="courseId" cssClass="input-text"/></td>
		</tr>
		<tr>
			<td width="20%">Description</td>
			<td width="*"><form:textarea path="description" cssClass="textarea"/></td>
		</tr>
		<tr>
			<td>Department<c:out value="${param.field_mandatory}" escapeXml="false"/></td>
			<td>
				<form:select path="department" cssClass="element-select">
					<form:option value="" label=""/>
					<form:options items="${departments}" itemValue="idAsString" itemLabel="name"/>
				</form:select>
			</td>
		</tr>
		<tr>
			<td>Batches<c:out value="${param.field_mandatory}" escapeXml="false"/></td>
			<td>
				<table>
					<c:set var="loopIndex" value="0"/>
					<c:forEach items="${batches}" var="eachBatch">
						<c:if test="${loopIndex%7 == 0}">
						<tr>
						</c:if>
							<td style="padding-right:2em;">
								<form:checkbox path="batch" value="${eachBatch}"/>
								&nbsp;<c:out value="${eachBatch}"/>
							</td>
						<c:if test="${(loopIndex != 0) && (loopIndex%6 == 0 || (batchSize - 1) == loopIndex)}">	
						</tr>
						</c:if>
					<c:set var="loopIndex" value="${loopIndex + 1}"/>	
					</c:forEach>
				</table>
			</td>
		</tr>
	</tbody>
</table>

<div class="subheader">Course Semester Brakeup Details:</div>
<table class="input-table">
	<tbody>
		<tr>
			<td width="20%">Semester Name</td>
			<td width="*"><input name="scname" class="input-text" value="<c:out value="${semName}" />" /></td>
		</tr>
		<tr>
			<td width="20%">Semester ID</td>
			<td width="*"><input name="scId" class="input-text" value="<c:out value="${semId}" />" /></td>
		</tr>
		<tr>
			<td width="20%">Description</td>
			<td width="*">
				<textarea name="scdescription" class="textarea"><c:out value="${semDescription}" /></textarea>
				&nbsp;&nbsp;
				<input type="button" value="Add" name="action_btn_add" onclick="doSubmit('action_add')" <c:out value="${disableBtn} "/> />
			</td>
		</tr>
	</tbody>
</table>
<table class="list-results-table" width="60%">
	<tbody>
		<tr>
			<th>Semester</th>
			<th>Semester ID</th>
			<th>Description</th>
			<th>&nbsp;</th>
		</tr>
		
		<c:forEach items="${command.subCourse}" var="semester">
		<tr>
			<td><c:out value="${semester.name}"/></td>
			<td><c:out value="${semester.subCourseId}"/></td>
			<td><c:out value="${semester.description}"/></tD>
			<td><input type="button" value="Remove" name="action_btn_remove" onclick="setSelectionValue('<c:out value="${semester.referenceId}"/>');doSubmit('action_remove')" <c:out value="${disableBtn} "/> /></tD>
		</tr>
		</c:forEach>
	</tbody>
</table>

<br/>

<div class="bottom-btn">
	<input type="button" value="Save" name="action_btn_save" onclick="doSubmit('action_save')" <c:out value="${disableBtn} "/> />
	<input type="button" value="Delete" name="action_btn_delete" onclick="doSubmit('action_delete')"  <c:out value="${disableBtn} "/> />
	<input type="button" value="Cancel" name="action_btn_cancel" onclick="doSubmit('action_cancel')"/>
</div>
</form:form>